package net.minecraft.src;

import java.util.ArrayList;
import java.util.Random;

public class LF_BlockTVOn extends LF_BlockFurnitureBase
{
	public LF_BlockTVOn(int i, int j, Class class1, Material mat)
	{
		super(i, j, class1, mat);
		setLightValue(100);
	}

	public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
	{
		LF_TileEntityTV tv = (LF_TileEntityTV)(world.getBlockTileEntity(i,j,k));
		tv.channel++;

		if(tv.channel > 8)
			tv.channel = 1;

		return true;
	}

	public void onNeighborBlockChange(World world, int i, int j, int k, int l)
	{
		world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
	}

	public void updateTick(World world, int i, int j, int k, Random random)
	{
		int m = world.getBlockMetadata(i,j,k);
		if(!world.isBlockIndirectlyGettingPowered(i,j,k))
		{
			if(world.getBlockId(i,j,k) == this.blockID)
			{
				world.setBlockAndMetadata(i, j, k, mod_LF_GenericFurnitureMain.blockTVOff.blockID, m);
				world.scheduleBlockUpdate(i, j, k, mod_LF_GenericFurnitureMain.blockTVOff.blockID, tickRate());
			}
		}
		else
		{
			LF_TileEntityTV tile = ((LF_TileEntityTV)world.getBlockTileEntity(i, j, k));
			mod_LF_GenericFurnitureMain mod = (mod_LF_GenericFurnitureMain)ModLoaderMp.getModInstance(mod_LF_GenericFurnitureMain.class);
			tile.frame++;

			if(tile.frame > mod_LF_GenericFurnitureMain.getChannelFrames(tile.channel))
				tile.frame = 1;

			world.scheduleBlockUpdate(i, j, k, this.blockID, tickRate());
		}
	}

	public int tickRate()
	{
		return 5;
	}

	public int idDropped(int i, Random random, int j)
	{
		return mod_LF_GenericFurnitureMain.itemTV.shiftedIndex;
	}
}
